function MessUIElement() {
	/**
	* Unique object identifier.
	*
	* @public
	* @property id
	* @type     String
	* @default  null;
	*/
	this.id = null;

    /**
	* Control height
	*
	* @public
	* @property controlHeight
	* @type     Number
	* @default  null
	*/
	this.controlHeight = null;

    /**
    * Control width
    *
    * @public
    * @property controlWidth
    * @type     Number
    * @default  null
    */
    this.controlWidth = null;

    /**
    * Control dom object representation.
    *
    * @private
    * @property  domObject
    * @type      DOM
    * @default   null
    */
    this.domObject = null;

    /**
    * Control immidiate parent control.
    *
    * @private
    * @property  parent
    * @type      Object
    * @default   null
    */
    this.parent = null;

    /**
    * Control theme selector. Applies to all child controls.
    *
    * @private
    * @property  theme
    * @type      String
    * @default   null
    */
    this.theme = "default";

    /**
    * Control opacity
    *
    * @private
    * @property  opacity
    * @type      String
    * @default   null
    */
    this.opacity = null;

    /**
    * Control disabled property
    *
    * @private
    * @property  disabled
    * @type      Boolean
    * @default   false
    */
    this.disabled = false;

    this.HORIZONTAL = "HR";
	this.VERTICAL   = "VR";
}

    /**
    * Method saves corelation between tag name (from xml data) and control class name, responsible
    * from control creation.
    *
    * @public
    * @method  addTagMapping 
    */
    MessUIElement.prototype.addTagMapping = function(tagName, relatedClassName) {

        var mappings = MessUIElement.prototype.tagMappings;
        if (!mappings) {
            MessUIElement.prototype.tagMappings = new Map();
        }

        MessUIElement.prototype.tagMappings.put(tagName, relatedClassName);
    };


// [PUBLIC]
// saves object instance in objects map - used by event handlers to get reference
// to actual objects responding to event
//
MessUIElement.prototype.saveObjectInstance = function(suffix) {
	
	var objects = MessUIElement.prototype.objects;
	if (!objects) {
		MessUIElement.prototype.objects = new Map();
	}

    MessUIElement.prototype.objects.put(this.id, this);
}


// [PUBLIC]
// function sets unique object id with specified prefix
//
MessUIElement.prototype.setObjectId = function(prefix) {
	if (!MessUIElement.id) {
		MessUIElement.id = 0;
	}
	this.id = prefix + MessUIElement.id++;
};

    /**
    * Basic control initialization routine - set id and save object instance
    *
    * @public
    * @method   initControl
    */
    MessUIElement.prototype.initControl = function() {

        var objects = MessUIElement.prototype.objects;
	    if (!objects || (objects && !objects.get(this.getId())) ) {
            // initialize unique splitter id
            this.setObjectId(this.getId());
            // save object instance in global map
            this.saveObjectInstance();
        }
    }


// [PUBLIC]
// returns object unique id
//
MessUIElement.prototype.getId = function() {
    
    return this.id !== null ? this.id : this.cssPrefix+"_";
};


// [PUBLIC]
// return dom representation
MessUIElement.prototype.render = function() {
	return this.domObject;
};


// [PUBLIC]
// destroy dom object - remove from objects tree && garbage collect obj. instance
//
MessUIElement.prototype.destroy = function() {
	try {
		// remove from dom structure
		this.domObject.parentNode.removeChild(this.domObject);
        // collect object
        gc.collect(this);
    }
	catch (ex) {}
	//
	return null;
};


// [PUBLIC]
// get element offset left
MessUIElement.prototype.getOffsetLeft = function(object) {

    var target = this.domObject;
    var args = MessUIElement.prototype.getOffsetLeft.arguments;
    if (args.length === 1) {
        target = args[0];
    }

    var offsetLeft = target.offsetLeft;
	var offsetParent = target.offsetParent;

	while (offsetParent instanceof MessUIElement) {
		offsetLeft += offsetParent.offsetLeft;
		offsetParent = offsetParent.offsetParent;
	}
	//
	return offsetLeft;
};


// [PUBLIC]
// get element offset top
MessUIElement.prototype.getOffsetTop = function(object) {

    var target = this.domObject;
    var args = MessUIElement.prototype.getOffsetTop.arguments;
    if (args.length === 1) {
        target = args[0];
    }
    
    var offsetTop = target.offsetTop;
	var offsetParent = target.offsetParent;

	while (offsetParent instanceof MessUIElement) {
		offsetTop += offsetParent.offsetTop;
		offsetParent = offsetParent.offsetParent;
	}
	//
	return offsetTop;
};


// [PUBLIC]
// get css width 
MessUIElement.prototype.getWidth = function() {

    var target = this.domObject;
    var args = MessUIElement.prototype.getWidth.arguments;
    if (args.length === 1) {
        target = args[0];
    }

    return target ? parseInt(target.style.width) : null;
};


// [PUBLIC]
// set css width (in px)
MessUIElement.prototype.setWidth = function(width, object) {

    var target = this.domObject;
	var args = MessUIElement.prototype.setWidth.arguments;
	if (args.length === 2) {
		target = args[1];
	} 

    if (target !== null) {
        target.style.width = width+"px";
    }
    else {
        // save width for later usage in initialized control object
        this.width = width;
    }
};


// [PUBLIC]
// get css height (xxxxpx -> xxx)
MessUIElement.prototype.getHeight = function() {

    var target = this.domObject;
    var args = MessUIElement.prototype.getHeight.arguments;
    if (args.length === 1) {
        target = args[0];
    }

    return target ? parseInt(target.style.height) : null;
};


// [PUBLIC]
// set css height (in px)
MessUIElement.prototype.setHeight = function(height, object) {
	
	var target = this.domObject;
	var args = MessUIElement.prototype.setHeight.arguments;
	if (args.length === 2) {
		target = args[1];
	}

    if (target !== null) {
        target.style.height = height+"px";
    }
    else {
        // save height for later usage in initialized control object
        this.height = height;
    }
};
	
	/**
	 * Set left control position
	 * 
	 * @public
	 * @method  setLeft
	 * @param   {Number} left
	 */
	MessUIElement.prototype.setLeft = function(left, object) {

        var target = (MessUIElement.prototype.setLeft.arguments[1] ? MessUIElement.prototype.setLeft.arguments[1] : this.domObject);
		target.style.left = left+"px";
	};
	 
	 /**
	  * Return left control position
	  * 
	  * @public
	  * @method  getLeft
	  * @return  {Number}
	  */
	MessUIElement.prototype.getLeft = function() {
		
		return parseInt(this.domObject.style.left);
	};
	
	/**
	 * Set top control position
	 * 
	 * @public
	 * @method  setTop
	 * @param   {Number} top
	 */
	MessUIElement.prototype.setTop = function(top, object) {
		
		var target = (MessUIElement.prototype.setTop.arguments[1] ? MessUIElement.prototype.setTop.arguments[1] : this.domObject);
		target.style.top = top+"px";
	}; 
	 
	/**
	 * Get top control position
	 * 
	 * @public
	 * @method  getTop
	 * @return  {Number}
	 */
	MessUIElement.prototype.getTop = function() {
		
		return parseInt(this.domObject.style.top);
	};

    /**
    * Parent property getter.
    *
    * @public
    * @method getParent
    * @return {Object} control parent
    */
    MessUIElement.prototype.getParent = function() {

        return this.parent;
    };

    /**
    * Parent property setter. Sets control parent to specified element.
    *
    * @public
    * @method setParent
    * @param {Object) parent object
    */
    MessUIElement.prototype.setParent = function(parent) {

        this.parent = parent;
    };

    /**
    * Set control theme
    *
    * @public
    * @method  setTheme
    * @param   {String} theme   theme selector string
    */
    MessUIElement.prototype.setTheme = function(theme) {

        this.theme = theme;    
    };

    /**
    * Get control theme string
    *
    * @public
    * @method  getTheme
    * @return  {String} theme string selector
    */
    MessUIElement.prototype.getTheme = function() {

        return this.theme;    
    };

    /**
    * Object cloning function.
    *
    * @public
    * @method  clone
    * @param  {Object} source   source object
    * @param  {Object} target   target object
    * @return {Object} target   complete clone of source object
    */
    MessUIElement.prototype.clone = function(source, target) {

        for (var field in source) {

            var expr = "target."+field+" = source."+field+";";
            eval(expr);
        }
        //
        return target;
    };

    /**
    * Fill 'this' object instance from source object. Rewrite all field values from source to "this".
    *
    * @public
    * @method  fillFromObject
    * @param   {MessUIElement} source  source object to take field values from
    */
    MessUIElement.prototype.fillFromObject = function(source) {

        for (var field in source) {

            var expr = "this."+field+" = source."+field+";";
            eval(expr);
        }
    }
	
	/**
	* Returns control height
	*
	* @public
	* @method getControlHeight
	* @return {Number} control height
	*/
	MessUIElement.prototype.getControlHeight = function() {
		
		return this.controlHeight;
	};

    /**
    * Default min height for control
    *
    * @public
    * @method  getMinHeight
    * @return  {Number} control min height
    */
    MessUIElement.prototype.getMinHeight = function() {
        return new Number(20);
    };

    /**
    * Retuns control width
    *
    * @public
    * @method  getControlWidth
    * @return  {Number} control width
    */
    MessUIElement.prototype.getControlWidth = function() {

        return this.controlWidth;
    }

    /**
    *  Writes DOM object to domObject object property, initializes dimensions
    *
    * @public
    * @method  setDomObject
    * @param   {DOM} object  control dom representation
    * @param   {Boolean} height   shwould the height be inherited from parent control
    * @param   {Boolean} width    should the width be inherited from parent control
    */
    MessUIElement.prototype.setDomObject = function(object, height, width) {

        this.domObject = object;

        // determine height to be set
        var height = this.parent.getHeight();
        if (this.parent.getControlContentHeight) {
            height = this.parent.getControlContentHeight();
        }

        // determine width to be set
        var width = this.parent.getWidth();
        if (this.parent.getControlContentWidth) {
            width = this.parent.getControlContentWidth();
        }

        var args = MessUIElement.prototype.setDomObject.arguments;
        if (args.length === 1) {
        // default behaviour, inherit both dimensions
            this.setHeight(height);
            this.setWidth(width);
        }
        else if (args.length === 3) {
            if (args[1]) {
            // inherit height
                this.setHeight(height);
            }
            if (args[2]) {
            // inherit width
                this.setWidth(width);
            }
        }

        // update opacity
        if (this.opacity) {
            this.domObject.style.opacity = this.opacity;
        }
    };
    
    /**
     * Return application ROOT panel, main parent of all other objects
     * 
     * @public
     * @method  getRootPanel
     * @return  {Panel} app. root panel
     */
	MessUIElement.prototype.getRootPanel = function() {

	    return env.getRootPanel();
    };

    /**
    * Dummy invalidate method, should be overriden in inheriting control
    *
    * @public
    * @method  invalidate
    */
    MessUIElement.prototype.invalidate = function() {
        return;
    }

    /**
    * Control disabled property setter
    *
    * @public
    * @method   disable
    */
    MessUIElement.prototype.disable = function() {

        this.disabled = true;
    };

    /**
    * Control disabled property setter
    *
    * @public
    * @method  enable
    */
    MessUIElement.prototype.enable = function() {

        this.disabled = false;
    };

    /**
    * Control disabled property getter
    *
    * @public
    * @method  isDisabled
    * @return  {Boolean}
    */
    MessUIElement.prototype.isDisabled = function() {

        return this.disabled;   
    };

	/**
	 * Returns basic css prefix common for all object elements
	 *
	 * @private
	 * @method  getCssPrefix
	 * @return  {String} common css prefix
	 */
	MessUIElement.prototype.getCssPrefix = function() {

		this.cssPrefix = this.cssPrefix + this.getTheme();
		this.getCssPrefix = function() { return this.cssPrefix; }; // overwrite method
		return this.cssPrefix;
	};

    /**
    * Returns next 'sibling' control (direction: right, bottom)
    *
    * @public
    * @method  getNextSibling
    * @return  {MessUIElemnet}  next sibling window
    */
    MessUIElement.prototype.getNextSibling = function() {

        try {
            if (this.parent instanceof Panel) {
                var sibling = this.parent.getNextSibling();

                if (sibling.getControl()) {
                    return sibling.getControl();
                }
                else {
                    return sibling;
                }
            }
            else {
                return this.parent.getNextSibling(this);
            }
        }
        catch (ex) {
            return null;
        }
    };

    /**
    * Returns prev sibling control (direction: left, top)
    *
    * @public
    * @method  getPrevSibling
    * @return  {MessUIElement}  prev sibling window
    */
    MessUIElement.prototype.getPrevSibling = function() {

        try {
            if (this.parent instanceof Panel) { 
                var sibling = this.parent.getPrevSibling();

                if (sibling.getControl()) {
                    return sibling.getControl();
                }
                else {
                    return sibling;
                }

            }
            else {
                return this.parent.getPrevSibling(this);
            }
        }
        catch (ex) {
            return null;
        }
    };

    /**
    * Hide DOM element
    *
    * @public
    * @method  hide
    * @param   {DOM} element  DOM element to hide
    */
    MessUIElement.prototype.hide = function(element) {

        element.style.display = "none";
    };

    /**
    * Show DOM element
    *
    * @public
    * @method  show
    * @param   {DOM} element   DOM element to show
    */
    MessUIElement.prototype.show = function(element) {

        element.style.display = "block";    
    };

    /**
    * Window opacity property setter
    *
    * @public
    * @method  setOpacity
    * @param   {String} opacity  opacity value
    */
    MessUIElement.prototype.setOpacity = function(opacity) {
        this.opacity = opacity;
    }

    /**
    * z-index css proprty getter
    *
    * @public
    * @method  getZIndex
    * @return  z-index of control
    */
    MessUIElement.prototype.getZIndex = function() {

        return this.domObject.style.zIndex;
    }

    /**
    * z-index css property setter
    *
    * @public
    * @method  setZIndex
    * @param   {Number} zIndex   z-index to set
    */
    MessUIElement.prototype.setZIndex = function(zIndex) {

        this.domObject.style.zIndex = zIndex;
    }

    /**
    * Checks if the cotrol has been build - has proper dom representation
    *
    * @public
    * @method  isBuild
    * @return  {Boolean}  true if the control has a DOM representation
    */
    MessUIElement.prototype.isBuild = function() {

        return this.domObject !== null;
    }

    /**
     * Builds basic child control object. Used in buildChildControls method by all
     * ui controls.
     *
     * @private
     * @method  buildChildControlObjec
     * @param   {MessUIElement} child control to be build
     * @return  {MessUIElement} child control in 'built' state
     */
     MessUIElement.prototype.buildChildControlObject = function(control) {

         control.setParent(this);
         if (control.getTheme() === null) {
            control.setTheme(this.getTheme()); // theme inheritance
         }
         control.build();

         return control;
     }

    










